package com.sctvcloud.renhe.ui.adapter.holder;

import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Pair;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.gridsum.tracker.GridsumWebDissector;
import com.jiongbull.jlog.JLog;
import com.ruihang.generalibrary.ui.widget.CustomFontTextView;
import com.ruihang.generalibrary.utils.DateUtils;
import com.sctvcloud.renhe.R;
import com.sctvcloud.renhe.base.BaseActivity;
import com.sctvcloud.renhe.beans.LiveItem;
import com.sctvcloud.renhe.beans.NewsItem;
import com.sctvcloud.renhe.ui.activities.LivingActivity;
import com.sctvcloud.renhe.ui.utils.GlideUtil;
import com.sctvcloud.renhe.ui.utils.SkipUtil;
import com.sctvcloud.renhe.ui.widget.BasePlayerView;

import java.util.ArrayList;
import java.util.HashMap;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class VideoPlayHolder extends RecyclerView.ViewHolder {

    public ImageView coverImg;
    public BasePlayerView videoPlayer;
    public ImageView noUrlImg;
    public CustomFontTextView title;
    public CustomFontTextView doUp;//点赞
    private Context context;
//    private NewsItemClickListener listener;
//    private NewsItemTitleClickListener titleClickListener;
//    private NewsItemDoUpClickListener doUpClickListener;
    private boolean isCanPlay = false;

    public VideoPlayHolder(View view) {
        super(view);
        videoPlayer = (BasePlayerView) view.findViewById(R.id.video_player);
        title = (CustomFontTextView) view.findViewById(R.id.video_title);
        noUrlImg = (ImageView) view.findViewById(R.id.no_url_img);
        coverImg = (ImageView) view.findViewById(R.id.top_bg_img);
        doUp = (CustomFontTextView)view.findViewById(R.id.comment_layout_doup);
    }


    public void playVideo() {
        if (null != videoPlayer && isCanPlay) {
            videoPlayer.startPlayLogic();
            videoPlayer.setEnabled(true);
        }
        coverImg.setVisibility(View.GONE);
    }

    public void pauseVideo() {
        if (null != videoPlayer && isCanPlay) {
            videoPlayer.onVideoPause();
            videoPlayer.setEnabled(false);
            videoPlayer.release();
        }
        coverImg.setVisibility(View.VISIBLE);
    }

    public void setMute(boolean isMute) {
        videoPlayer.setMute(isMute);
    }

    public void setCanPlay(boolean canPlay) {
        isCanPlay = canPlay;
    }

    public interface NewsItemTitleClickListener {
        void OnItemTitleClick(int position, NewsItem item);
    }

    public interface NewsItemClickListener {
        void OnItemClick(int position);
    }

    public interface NewsItemDoUpClickListener {
        void OnItemDoUpClick(int position,String newsId);
    }
}
